﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GameStarter : MonoBehaviour 
{
    public string[] Infos;
    public string[] mapName;
    public Vector2[] StartPos;

	// Use this for initialization
	void Start ()
    {
        Vector2 a = new Vector2(0.0f, 100.0f);
        Vector2 b = new Vector2(471573.125f, 100.0f);
        Vector2 c = new Vector2(6.1f, 0.0f);
        
        List<MyMathHelp.MultiSegmentFunction.Segment> l1 = MyMathHelp.MultiSegmentFunction.Build(new List<Vector2>() {a, b, c});


        Vector2 a1 = new Vector2(0.0f, 100.093246f);
        Vector2 b1= new Vector2(0.0144973956f, 100.0f);

        List<MyMathHelp.MultiSegmentFunction.Segment> l2 = MyMathHelp.MultiSegmentFunction.Build(new List<Vector2>() { a1, b1 });

        Vector2 v = MyMathHelp.MultiSegmentFunction.DoFunction(l1, l2); //v.x为改变的能量   v.y为终点温度 考虑到 可能发生溶解了一半的状态  分别将2个物体 修改能量



        UnityEngine.UI.Button[] buttons = GetComponentsInChildren<UnityEngine.UI.Button>();
        for (int i = 0; i < buttons.Length; i++)
        {
            int j = i;
            buttons[i].GetComponentInChildren<UnityEngine.UI.Text>().text = Infos[i];
            buttons[i].onClick.AddListener(() =>
                {
                    MainGame.DC.mapName = this.mapName[j];
                    MainGame.DC.startPosition = this.StartPos[j];
                    UnityEngine.SceneManagement.SceneManager.LoadScene("Main");
                });
        }
	}
	
	// Update is called once per frame
	void Update () 
    {
		
	}
}
